package designpattern.flyweight;

import java.util.HashMap;
import java.util.Map;

public class FlyweightFactory {
    
    private static final Map<String,IFlyWeight> pool = new HashMap<>();

    public static IFlyWeight getFlyweight(String intrinsicState){
        if (!pool.containsKey(intrinsicState)) {
            ConcreteFlyweight flyweight = new ConcreteFlyweight(intrinsicState);
            pool.put(intrinsicState,flyweight);
        }
        return pool.get(intrinsicState);
    }
}
